package com.chenl.consumer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.ConfigurableEnvironment;

import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@Slf4j
@ComponentScan(basePackages = {"com.chenl"}) //如果项目中有@ComponentScan,可能会覆盖掉@SpringBootApplication里的？,可以手动扫包,同时加上启动类自动扫的那些
public class ConApplication {
    public static void main(String[] args) throws UnknownHostException {
//        SpringApplication.run(ConApplication.class,args);
        SpringApplication springApplication=new SpringApplication(ConApplication.class);
        ConfigurableEnvironment env = null;
        try {
            env = springApplication.run(args).getEnvironment();
        } catch (Throwable e) {
            throw new RuntimeException(e);
        }
        log.info("\n----------------------------------------------------------\n\t" +
                        "Local: \t\thttp://localhost:{}\n\t" +
                        "External: \thttp://{}:{}\n\t" +
                        "----------------------------------------------------------",
                env.getProperty("server.port"),
                InetAddress.getLocalHost().getHostAddress(),
                env.getProperty("server.port"));


    }
}
